package xyz.thoughtset.viewer.common.crud.core.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class BaseMetaHandler implements MetaObjectHandler {
//    private Integer statesCode = 200;

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createdAt", Date.class, new Date());
        this.strictInsertFill(metaObject, "updatedAt", Date.class, new Date());
//        this.strictInsertFill(metaObject, "statesCode", Integer.class, statesCode);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.debug(metaObject.getOriginalObject().getClass().getSimpleName());
        this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
//        this.strictUpdateFill(metaObject, "statesCode", Integer.class, statesCode);
    }
}
